package com.zixi.beverage_order.controller.seller;

import com.zixi.beverage_order.pojo.ReturnOderListInfo;
import com.zixi.beverage_order.service.seller.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/pickup")
public class GetPickUpOrdersController {
    @Autowired
    OrdersService ordersService;

    @GetMapping("/all")

    public String getPickUpAllOrders(Model model){
        List<ReturnOderListInfo> returnOderListInfoList =  ordersService.getPickUpAllOrders();
        model.addAttribute("AllData",returnOderListInfoList);
        return "topmenu/pickup";
    }


    @GetMapping("/finish")
    public String finishedOrder(@RequestParam("id") String id){
        //查出原来的数据
        Long finishedId =  Long.valueOf(id);
        ordersService.finishedOrder(finishedId);
        return "redirect:/pickup/unfinished";
    }


    @GetMapping("/finished")
    public String getPickUpFinishedOrders(Model model){
        List<ReturnOderListInfo> returnOderListInfoList =  ordersService.getPickUpAllOrders();
        model.addAttribute("AllData",returnOderListInfoList);
        return "pickup/pickupfinished";
    }

    @GetMapping("/unfinished")
    public String getPickUpUnfinishedOrders(Model model){
        List<ReturnOderListInfo> returnOderListInfoList =  ordersService.getPickUpAllOrders();
        model.addAttribute("AllData",returnOderListInfoList);
        return "pickup/pickupunfinished";
    }
}

